<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/*
 * @author: Manh Nguyen
 * @email: manhnv@binhhoang.com
 * @date: 14.04.2012
 */

class Detect extends CI_Controller {
	
	function __construct()
	{
		parent::__construct();
		$this->load->model(array('location_model','mobile_detect_loto_model','result_model'));
		$this->load->helper('result');
	}
	
	public function index($alias = NULL)
	{
		//$this->load->model();
		$location	=	$this->location_model->get_by(array('alias' => $alias));
		$cur_date	=	date('y-m-d');
		$_data	=	array();
		if($location)
		{
			$_data	=	$this->mobile_detect_loto_model->get_by(array('lid' => $location->id, 'date' => $cur_date));
		}
		$data['data']	=	$_data;
		$data['tmpl']	=	'client/detect/index';
		$data['location']	=	$location;
		$this->load->view('client/layout/content', $data);
	}
	
	function view($alias = NULL, $number = NULL, $p_from = NULL, $p_to = NULL)
	{
		$location	=	$this->location_model->get_by(array('alias' => $alias));
		//$result		=	$this->result_model->select()->limit(6)->order_by('date','DESC')->get_all();
		$result		=	$this->result_model->get_detect($location->id);
		//echo '<pre>';
		//print_r($result);
		$data['result']	=	$result;
		$data['from']	=	$p_from;
		$data['to']		=	$p_to;
		$data['tmpl']	=	'client/detect/view';
		$data['location']	=	$location;
		$this->load->view('client/layout/content', $data);
	}
}

/* End of file home.php */
/* Location: ./application/controllers/home.php */